from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
import time
driver = webdriver.Edge()
driver.maximize_window()
driver.get('http://10.59.9.14:7003/')
driver.find_element(By.XPATH,'/html/body/div[1]/div/div[2]/ul/li[1]/a').click()
driver.find_element(By.CLASS_NAME,'regi-input').send_keys('15232008902')
driver.find_element(By.NAME,'password').send_keys('123456')
time.sleep(15)
urad=WebDriverWait(driver,20,0.5).until(EC.presence_of_element_located((By.CSS_SELECTOR,'.finish-btn')))
urad.click()
dy1=driver.find_element(By.XPATH,'/html/body/div[1]/div/div[2]/ul/li[1]/a').text
print(dy1)
# 点击首页
driver.find_element(By.XPATH,'/html/body/div[3]/div[2]/ul/li[1]/a').click()
time.sleep(2)
keys=driver.find_element(By.TAG_NAME,'input')
keys.send_keys('龙虾')
keys.send_keys(Keys.ENTER)

driver.find_element(By.CLASS_NAME,'lazy').click()
time.sleep(5)
driver.find_element(By.ID,'add-cart').click()
time.sleep(5)
driver.find_element(By.LINK_TEXT,'立即购买').click()
time.sleep(5)
driver.execute_script('window.scrollTo(0,document.body.scroollHeight)')
driver.find_element(By.ID,'order-button').click()
time.sleep(5)
jubing=driver.window_handles
print('所有窗口句柄',jubing)
driver.switch_to.window(driver.window_handles[-1])


time.sleep(10)
driver.quit()
